package com.sws.quartz.task;

import com.sws.capture.domain.CapRecord;
import com.sws.capture.mapper.CapRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CapRecordTask {

    @Autowired
    private CapRecordMapper capRecordMapper;

    /**
     * 定时删除抓拍记录
     */
    public void deleteCapRecordTask() {
        // 查询超过七天的抓拍记录
        List<CapRecord> capRecords = capRecordMapper.selectTimeoutCapRecordList();
        // 删除超过七天的抓拍记录
        capRecordMapper.deleteCapRecordByIds(capRecords.stream().map(CapRecord::getId).toArray(Integer[]::new));
    }
}
